package com.hsogoo.study.concurrency.disruptor;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;

/**
 * Created by za-huangsaigang on 2018/10/26.
 */
public class ConsumerHandler implements EventHandler<TaskEvent>, WorkHandler<TaskEvent> {

    //EventHandler
    @Override
    public void onEvent(TaskEvent taskEvent, long sequence, boolean endOfBatch) throws Exception {
        Task task = taskEvent.getTask();
        System.out.println("EventHandler" + task.call());
    }

    //WorkHandler
    @Override
    public void onEvent(TaskEvent taskEvent) throws Exception {
        Task task = taskEvent.getTask();
        System.out.println("WorkHandler" + task.call());
    }
}
